from django.shortcuts import render
from rest_framework.views import APIView
from .models import User
from rest_framework.response import Response


# Create your views here.

# APIView
# GenericAPIView
# ListAPIView,RetrieveAPIView

# 是否用到序列化器
# 此视图没有用到序列化器,所以 不需要列表或者详情视图的支持,所以选项APIView
class RegisterUserNameView(APIView):
    def get(self, request, username):
        print(username)
        i = 0
        while True:


            count = User.objects.filter(username=username).count() + i
            print(username)
            context = {
                'count': count,
                'name': username
            }
            i += 1

            return Response(context)




